package com.lablzh.gdxy.repository.assistant;

import com.lablzh.gdxy.entity.assistant.Assistant;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

public interface AssistantRepository extends JpaRepository<Assistant, Integer> {
    Assistant findByName(String name);

    List<Assistant> findAllByCollegeAndGradeAndCategory(String category, String grade, String category1);

    List<Assistant> findAllByCollegeAndMajorAndGradeAndCategory(String college, String major, String grade, String category);

    @Modifying
    @Transactional
    @Query("update Assistant set applyed=?2 where id=?1")
    void updateApplyedById(Integer id, int applyed);

    @Modifying
    @Transactional
    @Query("update Assistant set recv=?2 where id=?1")
    void updateRecvById(Integer id, int recv);

    List<Assistant> findAllByCollegeAndGrade(String college, String grade);

    @Modifying
    @Transactional
    @Query("update Assistant set recv=?2, applyed=?3 where id=?1")
    void updateRecvAndApplyedById(Integer id, int i, int i1);
}
